import java.util.Scanner;
import java.util.Stack;

public class test6 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        System.out.println(getResult(str));
    }

    public static boolean getResult(String str){
        if(str.isEmpty()){
            return true;
        }
        //用栈,后进先出
        Stack<Character> stack = new Stack<>();
        char[] chars = str.toCharArray(); // 转换成数组
        for (int i = 0; i < chars.length; i++) {
             if(chars[i] == '(' || chars[i] == '{' || chars[i] == '['){
                 stack.push(chars[i]);
             }
             else {
                 // 右括号
                 if(stack.isEmpty())
                     return false;
                 char ch = stack.peek();
                 if((ch=='('&&chars[i]==')')||(ch=='{'&&chars[i]=='}')||(ch=='['&&chars[i]==']'))
                     stack.pop();
                 else
                     return false;
             }
        }
        if(stack.isEmpty()){
            return true;
        }else
            return false;
    }
}
